/**
 * 更改头像信息
 */
export const UPDATEAVATAR = 'UPDATE user set avatar=? WHERE id=?';

/**
 * 获取旧的头像信息
 */
export const GETOLDAVATAR = 'SELECT avatar FROM user WHERE id=?';


/**
 * 更改用户名
 */
export const UPDATEUSERNAME = 'UPDATE user set username=? WHERE id=?';


/**
 * 更改密码
 */
export const UPDATEPASS = 'UPDATE user set password=? WHERE id=?';

/**
 * 查看密码
 */
export const CHECKPASS = 'SELECT * FROM user WHERE id=? AND password=?';


// export const GETFOLLOWS = `SELECT JSON_ARRAY(JSON_OBJECT('id', u.id, 'username', u.username, 'avatar', u.avatar, 'follow_time', f.create_time, 'intro', u.intro, 'motto', u.motto
//  )) followIds from follow f LEFT JOIN user u ON f.follower_id=u.id  WHERE user_id=?`


// export const GETFOLLOWERS = `SELECT JSON_ARRAY(JSON_OBJECT('id', u.id, 'username', u.username, 'avatar', u.avatar, 'follow_time', f.create_time, 'intro', u.intro, 'motto', u.motto
// )) followIds from follow f LEFT JOIN user u ON f.user_id=u.id  WHERE follower_id=?`


export const BASEUSERINFO = `SELECT id, username, avatar, role, create_time FROM user `
/** 
* 通过id获取用户信息
*/
export const GETUSERINFOBYID =
    BASEUSERINFO + `WHERE id=?`;


/**
 * 更改格言
 */
export const UPDATEMOTTO = `UPDATE user set motto=? WHERE id=?`

/**
 * 更改个人介绍
 */
export const UPDATEINTRO = `UPDATE user set intro=? WHERE id=?`

/**
 * 更改职位
 */
export const UPDATEOCCUP = 'UPDATE user set occup=? WHERE id=?'

/**
 * 关注用户
 */
export const FOLLOW = `INSERT INTO follow (user_id, follower_id) VALUES(?, ?)`

/**
 * 获取关注的用户
 */
export const GETFOLLOW = `SELECT * FROM follow WHERE user_id=? AND follower_id=?`

/**
 * 取消关注
 */
export const CANCELFOLLOW = `DELETE FROM follow WHERE user_id=? AND follower_id=?`


/**
 * 获取用户关注者的所有id
 */
export const GETFOLLOWS = `SELECT u.id id ,  u.username username, u.avatar avatar, f.create_time follow_time, u.intro intro , u.motto motto
from follow f LEFT JOIN user u ON f.follower_id=u.id  WHERE user_id=?`


/**
 * 获取所有关注用户的用户
 */
export const GETFOLLOWERS = `SELECT u.id id ,  u.username username, u.avatar avatar, f.create_time follow_time, u.intro intro , u.motto motto
from follow f LEFT JOIN user u ON f.user_id=u.id  WHERE follower_id=?`

